<template>
  <div>
    <div class="rditop">
      <div class="blk f-fl">
        <div class="u-title">
          <h3>
            <router-link :to="{name:'MoreView',params:{type:'recommend'}}" class="f-ff2">
              推荐节目
            </router-link>

          </h3>
          <router-link :to="{name:'MoreView',params:{type:'recommend'}}" class="more">更多></router-link>
        </div>
        <ul class="m-plylist">
          <li class="it" v-for="(item,index) in ProgramList" :key="index">
            <a href="#" class="u-cover">
              <img v-lazy="item.coverUrl" alt="">
              <i class="play" title="播放"></i>
            </a>
            <div class="cnt">
              <h3 class="f-thide">
                <router-link :to="{name:'ProgramDetail',query: {id:item.id}}" :title="item.name" class="s-sf1">{{item.name}}</router-link>
              </h3>
              <p class="f-thide">
                <router-link :to="{name:'DjRadioDetail',query:{id:item.radio.id}}" class="s-fc4" :title="item.radio.name">{{item.radio.name}}</router-link>
              </p>
            </div>
            <router-link :to="{name:'DjRadioView',query:{id:item.radio.categoryId}}" class="tag">
              {{item.radio.category}}
            </router-link>
          </li>
        </ul>
      </div>

      <div class="blk f-fr">
        <div class="u-title">
          <h3>
            <router-link :to="{name:'MoreView',params:{type:'rank'}}" class="f-ff2">
              节目排行榜
            </router-link>

          </h3>
          <router-link :to="{name:'MoreView',params:{type:'rank'}}" class="more">更多></router-link>
        </div>
        <ul class="m-plylist">
          <li class="it" v-for="(item,index) in TopProgramList" :key="index">
            <div class="rank">
              <em class="f-fs1">{{num(index+1)}}</em>
            </div>
            <a class="u-cover" style="margin-left: 0" title="播放">
              <img v-lazy="item.program.coverUrl" alt="">
              <i class="play" ></i>
            </a>
            <div class="cnt" style="width: 208px;">
              <h3 class="f-thide">
                <router-link :to="{name:'ProgramDetail',query: {id:item.program.id}}" :title="item.program.name" class="s-sf1">{{item.program.name}}</router-link>
              </h3>
              <p class="f-thide">
                <router-link :to="{name:'DjRadioDetail',query:{id:item.program.radio.id}}" class="s-fc4" :title="item.program.radio.name">{{item.program.dj.brand}}</router-link>
              </p>
            </div>
            <span class="u-hot">
          <i style="width: 92%;" class="fir">
            <i></i>
          </i>
        </span>
          </li>
        </ul>
      </div>

    </div>
    <div class="rdimore" v-for="(dj,index) in RadioList" :key="index">
      <div class="u-title">
        <h3>
          <a href="#" class="f-ff2">
            {{dj.name}}·电台
          </a>
        </h3>
        <router-link :to="{name:'DjRadioView',query:{id:dj.id}}" class="more">更多></router-link>
      </div>
      <ul class="rdilist">
        <li v-for="(item,i) in dj.Radios" :key="i">
          <a href="#" class="u-cover-rdi">
            <img v-lazy="item.intervenePicUrl" alt="">
          </a>
          <div class="cntr">
            <h3 class="f-fs3">
              <a href="#" class="s-fc1" :title="item.name">{{item.name}}</a>
            </h3>
            <p class="note" :title="item.rcmdtext">{{ item.rcmdtext }}</p>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>

export default {
  name: "index",
  data(){
    return {
      ProgramList:[],
      TopProgramList:[],
      id:[2,6,3,2001,11],
      RadioList:[
        {
          id:2,
          name:'音乐推荐',
          Radios:[]
        },
        {
          id:6,
          name:'生活',
          Radios:[]
        },
        {
          id:3,
          name:'情感',
          Radios:[]
        },
        {
          id:2001,
          name:'创造翻唱',
          Radios:[]
        },
        {
          id:11,
          name:'知识',
          Radios:[]
        },
      ],

    }
  },
  methods:{
    num(index){
      if (index<10) {
        return `0${index}`
      }
      return index
    },
    async getProgramList() {
      let result = await this.$API.reqProgramList();
      this.ProgramList = result.data.programs
    },
    async getTopProgramList() {
      let result = await this.$API.reqTopProgramList();
      this.TopProgramList = result.data.toplist
    },
    async getRadio() {
     for (let i = 0;i<this.id.length;i++){
       let result = await this.$API.reqRadio(this.id[i]);

       this.RadioList[i].Radios = result.data.djRadios.slice(0,4)
     }
    },
  },
  mounted() {
    this.getProgramList()
    this.getTopProgramList()
    this.getRadio()
  }
}
</script>

<style scoped lang="less">
.rditop {
  width: 900px;
  margin: 0 auto;
  height: auto;
  overflow: hidden;
  margin-top: 10px;

  .blk {
    width: 426px;

    .u-title {
      height: 40px;
      border-bottom: 2px solid #c20c0c;

      h3 {

        float: left;
        font-size: 24px;
        font-weight: normal;

        .f-ff2 {
          color: #000;
          font-family: "Microsoft Yahei", Arial, Helvetica, sans-serif;
        }
      }

      .more {
        font-size: 12px;
        float: right;
        margin-top: 14px;
        color: #666;
      }

    }
    .m-plylist{
      height: 600px;
      border-right: 1px solid rgb(226, 226, 226);
      border-bottom: 1px solid rgb(226, 226, 226);
      border-left: 1px solid rgb(226, 226, 226);
      border-image: initial;
      border-top: none;
      .it{
        width: 424px;
        height: 60px;
        padding: 10px 0px;
        line-height: 40px;
        float: left;
        background-color: #fff;
        &:nth-child(-n+3){
          .rank{
            em{
              color: rgb(218, 69, 69);
            }
          }
        }
        &:nth-child(even){
          background-color: #f7f7f7;
        }
        &:hover{
          background-color: #EEEEEE;
        }
        &:hover .u-cover .play{
          display: block;
        }
        .rank{
          float: left;
          width: 47px;
          height: 30px;
          text-align: center;

          margin: 6px 0px 0px;
          text-align: center;
          line-height: normal;
          em{
            display: block;
            width: 100%;
            line-height: 30px;
            text-align: center;
          }
        }
        .u-cover{
          margin-left: 20px;
          width: 40px;
          height: 40px;
          position: relative;
          display: block;
          float: left;
          img{
            display: block;
            width: 100%;
            height: 100%;
          }
          .play{
            position: absolute;
            display: none;
            _display: block;
            width: 22px;
            height: 22px;
            top: 50%;
            left: 50%;
            overflow: hidden;
            background-image: url("../../../assets/icn_ply.png");
            margin: -11px 0 0 -11px;
            background-position: 0 -87px;
          }
        }
        .cnt{
          float: left;
          width: 254px;
          margin: 1px 0px 0px 10px;
          line-height: 20px;
          .f-thide{
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            word-wrap: normal;
            .s-sf1{
              color: #333;
              font-weight: normal;
            }
            .s-fc4{
              color: #999;
            }
          }
        }
        .u-hot{
          margin-right: 15px;
          margin-top: 16px;
          display: block;
          height: 8px;
          float: right;
          position: relative;
          width: 100px;
          background-image: url("../../../assets/table.png");

          background-position: 0 -240px;
          line-height: normal;
           i {
             display: block;
             height: 8px;
            overflow: hidden;
            padding: 0 4px;
            background-position: right -318px;
             i{
               margin-left: -4px;
               padding: 0 0 0 4px;
               background-position: 0 -304px;
               background-image: url("../../../assets/table.png");
             }
          }


        }
        .tag{
          margin: 1px 0px 0px 10px;
          display: inline-block;
          position: relative;
          top: -1px;
          height: 16px;
          overflow: hidden;
          padding: 0 6px;
          border: 1px solid #999;
          line-height: 16px;
          *line-height: 18px;
          color: #999;
          vertical-align: middle;
          font-size: 12px;
        }
      }
    }
  }

  .f-fl {
    float: left;
  }
  .f-fr {
    float: right;
  }

}
.rdimore{
  width: 900px;
  margin: 0 auto;
  padding: 30px 0;
  height: auto;
  overflow: hidden;
  .u-title {
    height: 40px;
    border-bottom: 2px solid #c20c0c;

    h3 {

      float: left;
      font-size: 24px;
      font-weight: normal;

      .f-ff2 {
        color: #000;
        font-family: "Microsoft Yahei", Arial, Helvetica, sans-serif;
      }
    }

    .more {
      font-size: 12px;
      float: right;
      margin-top: 14px;
      color: #666;
    }

  }
  .rdilist{
    height: auto;
    overflow: hidden;
    margin-left: -30px;
    li{
      float: left;
      width: 435px;
      height: auto;
      overflow: hidden;
      margin-left: 30px;
      padding: 20px 0px;
      border-bottom: 1px solid rgb(231, 231, 231);
      .u-cover-rdi{
        margin-right: -200px;
        width: 120px;
        height: 120px;
        position: relative;
        display: block;
        float: left;
        img{
          display: block;
          width: 100%;
          height: 100%;
        }
      }
      .cntr{
        margin-left: 140px;
        .f-fs3{
          margin: 16px 0px 20px;
          .s-fc1{
            color: #333;
            font-size: 18px;
          }
        }
        .note{
          margin-bottom: 6px;
          line-height: 20px;
          color: #999;
        }
      }
    }
  }
}
</style>